package reflective;

import extend.Employee;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class ReflectiveTest3 {
    public static void main(String[] args) throws IllegalAccessException {
        Employee employee = new Employee("CJ", 8888, 24);
        Class<? extends Employee> cl = employee.getClass();

        // 获取字段类型和名称
        Field[] fields = cl.getDeclaredFields();
        for (Field field : fields) {
            System.out.println(field.getType().getName() + " " + field.getName());

        }
        System.out.println("====================================================");

        // 获取方法名
        Method[] methods = cl.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
        }

        System.out.println("====================================================");

        // 获取构造器
        Constructor<?>[] constructors = cl.getDeclaredConstructors();
//        for (Constructor<?> constructor : constructors) {
//            Parameter[] parameters = constructor.getParameters();
//        }


        System.out.println("====================================================");

        // 获取包名
        System.out.println(cl.getName());
    }
}
